/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import models.Supplier;
import db.SupplierInterface;
import db.SupplierDb;
import java.util.ArrayList;

/**
 *
 * @author Dan
 */


public class SupplierController {

    private boolean SupplierCreated;
    private Supplier supplier = null;
    
    private SupplierInterface supdb = new SupplierDb();

    public Boolean newSupplier(String email, String name, String address, String country, long phoneno) {

        Supplier supplier = new Supplier(email, name, address, country, phoneno);
        SupplierCreated = supdb.insertSup(supplier);
        return SupplierCreated;

    }

    public boolean updateSup(Supplier sup) {
        return supdb.updateSup(sup);

    }
    public Supplier getSupplier(int id)
    {
        return supdb.getSupplier(id);
    }

    public ArrayList<Supplier> searchSupplier(String name)
    {
        ArrayList<Supplier> supList = new ArrayList<Supplier>();
        supList = supdb.searchSupplier(name);
        return supList;
    }

    public void setSupplier(Supplier sup) {
        this.supplier = sup;
    }

    public Supplier getSupplier() {
        return this.supplier;
    }
    public int deleteSupplier(int Id)
    {
        return supdb.deleteSupplier(Id);
    }

}
